import router from 'umi/router';

import React from 'react';
import { connect } from 'dva';
import Link from 'umi/link'
import { Table, Button } from 'antd';

const linePath = '/Sale/SaleOrder';
const formPath = '/Sale/SaleOrderForm';

@connect(({ saleOrder }) => ({ saleOrder }))
class List extends React.Component {
  state = {
  }

  treeview = [
      {
        title: '',
        dataIndex: '_',
        render: (_, { id }) => {
          return <Link to={`${linePath}?id=${id}`}>查看</Link>;
        },
      },
      { title: '名称', dataIndex: 'name', },
//      { title: '愿单据', dataIndex: 'origin', },
//      { title: '客户单据号', dataIndex: 'client_order_ref', },
//      { title: '参考', dataIndex: 'reference', },
      { title: '状态', dataIndex: 'state', },
      { title: '日期', dataIndex: 'date_order', },
//      { title: '创建日期', dataIndex: 'create_date', },
//      { title: '生效日期', dataIndex: 'validity_date', },
//      { title: '确认日期', dataIndex: 'confirmation_date', },
      { title: '销售员', dataIndex: 'user_id.name', },
      { title: '业务伙伴', dataIndex: 'partner_id.name', },
//      { title: '发票数', dataIndex: 'invoice_count', },
      { title: '总金额', dataIndex: 'amount_total', },
      { title: '销售团队', dataIndex: 'team_id.name', },
  ]

  async componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'saleOrder/search',
      payload: {domain:[], },

    });
  }


  goto_createForm() {
      router.push(formPath);
  }


  render() {
    const { saleOrder: { recordsList } } = this.props;

    return (
      <div>

        <Button onClick={()=>this.goto_createForm()}>新建</Button>
        <Table columns={this.treeview} dataSource={recordsList} rowKey="id" />


      </div>
    );
  }
}

export default List;





